import { processXAis, processSeriesData } from './lineAndBarFormat.js';
import { handleChangeGroup }  from '../changeGroup.js';

// 堆叠图数据拦截动态拼装stack
export function stackBarChartFormat(datasets, extra) {
  const { selectStackOptions } = extra;
  const { dimensions } = datasets;
  const { yAxis, legend, xAxis, yAxisCondition } = dimensions;
  const xAxisData = processXAis(datasets);
  let seriesData = processSeriesData(datasets, {
    xData: xAxisData,
    yAxis,
    legend,
    xAxis,
    yAxisCondition,
    dataFormatType: 'yAxis',
  });
  seriesData= handleChangeGroup( seriesData, selectStackOptions) ;
  return {
    seriesData,
    xAxisData,
  };
}
